﻿//********************************************************************************//
//创建日期：<创建日期，2016-10-19>
//创建作者：<孙雪婷，sunxueting@shanghai3h.com>
//功能说明：补收
//********************************************************************************//
using BLL;
using BLL.Access;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Pages.QuShui.DiXiaS.ZhangWuGL
{
    public partial class BuShou : BasePage
    {
        #region 属性
        private DataTable dtGrid
        {
            get
            {
                return ViewState["dtGrid"] as DataTable;
            }
            set
            {
                ViewState["dtGrid"] = value;
            }
        }

      
        #endregion

        #region 变量
        /// <summary>
        /// 补收BLL
        /// </summary>
        QS_ZW_BUSHOU2BLL _BSBLL = new QS_ZW_BUSHOU2BLL();
        /// <summary>
        /// 用户信息BLL
        /// </summary>
        QS_YG_YONGHUXXBLL _YHXXBLL = new QS_YG_YONGHUXXBLL();
       
        /// <summary>
        /// 数据访问操作类
        /// </summary>
        SpHelper _spHelper = new SpHelper();
        /// <summary>
        /// 日志操作类
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();
        #endregion

        #region 事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
            this.gvGrid.DataSource = this.dtGrid;
            this.gvGrid.DataBind();
        }

        /// <summary>
        /// 取消内部转账
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void btnQuXiaoNBZZ_Click(object sender, EventArgs e)
        //{
        //    DataRow[] dr = this.dtGrid.Select("ID=" + this.HGF_ID);
        //    int bh_out = Convert.ToInt32(dr[0].ItemArray[4]);
        //    int bh_in = Convert.ToInt32(dr[0].ItemArray[5]);
        //    int clr = Convert.ToInt32(dr[0].ItemArray[3]);
        //    decimal je = Convert.ToInt32(dr[0].ItemArray[6]);
        //    int? result = -1;
        //    _spHelper.P_YS_ZW_NEIBUZZ(bh_out, bh_in, "", clr, je, this.HGF_ID, out result);
        //    if (result == 1)
        //    {
        //        InitData();
        //    }
        //}

      
        /// <summary>
        /// 前台表格行改变事件回调方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ASPxCallback1_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            string msg = "";
            string h = this.hdCollection.Get("id").ToString();
            if (e.Parameter == "setinfo")
            {
                DataTable dt = _YHXXBLL.SelectQS_YG_YONGHUXXesDynamic(string.Format("i_jlzt=0 and S_YONGHUH='{0}'", h), null);
                if (dt == null || dt.Rows.Count < 0)
                {
                    msg = string.Join("|", "-1","", "");
                }
                else
                {
                    msg = string.Join("|", "1", dt.Rows[0]["S_YONGHUM"].ToString(), dt.Rows[0]["N_SHUIJIA"].ToString());
                }
            }

            else if (e.Parameter == "qdbs")
            {
                string res = "";
                int wtype = 2;
                string yhh = txtBianHao.Text;
                string yhm = txtMingCheng.Text;
                decimal sj = Convert.ToDecimal(txtShuiJia.Text);
                int type = Convert.ToInt32(cmbBuShouLX.Value);
                int sl = Convert.ToInt32(txtBuShouSL.Text);
                decimal je = Convert.ToDecimal(txtBuShouJE.Text);
                string bz = memoBeiZhu.Text.ToString();
                string a = LoginInfo.CurrentUser.UserID.ToString(); 
                DateTime ti=DateTime.Now;
                _spHelper.P_QSZW_BUSHOU(1, 0, yhh, yhm, sj, sl, je, type, txtZWNY.Text, bz, wtype, 0,a,ti,a,ti, out res);
                msg = string.Join("|", Convert.ToString(res));
            }

            else if (e.Parameter == "qxbs")
            {
                string res = "";
                _spHelper.P_QSZW_BUSHOU(2, Convert.ToInt32(h), null, null, null, null, null, null, null, null, null, null, null, null, null, null, out res);
                msg = string.Join("|", Convert.ToString(res));
            }
            e.Result = e.Parameter + "|0|" + msg;
        }

        protected void gvGrid_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            LoadData();
        }

        #endregion

        #region 方法

        /// <summary>
        /// 页面加载
        /// </summary>
        private void InitData()
        {
            int wtype = BusinessTool.WType;
            txtZWNY.Text = BusinessTool.GetSLYMorZWNY(1, wtype).ToString();
        }


        private void LoadData() 
        {
            int wtype = BusinessTool.WType;
            //加载列表信息
            this.dtGrid = _BSBLL.SelectQS_ZW_BUSHOU2sDynamic(string.Format("i_jlzt=0 and i_wtype={0} AND S_BUSHOURQ='{1}'", wtype, txtZWNY.Text), null);
            this.gvGrid.DataSource = this.dtGrid;
            this.gvGrid.DataBind();
            if (this.dtGrid != null && this.dtGrid.Rows.Count > 0)
            {
                this.gvGrid.FocusedRowIndex = 0;
            }
        
        }
        #endregion

        protected void btnsx_Click(object sender, EventArgs e)
        {
            LoadData();
        }

       

    }
}